import axios, {AxiosInstance} from "axios";

// 创建实例时配置默认值
const myAxios:AxiosInstance = axios.create({
    baseURL: 'http://localhost:8080/api/'
});

myAxios.defaults.withCredentials = true; // 配置为true


// Add a request interceptor
myAxios.interceptors.request.use(function (config) {
    console.log('我要发请求啦', config)
    // Do something before request is sent
    return config;
}, function (error) {
    // Do something with request error
    return Promise.reject(error);
});

// Add a response interceptor
myAxios.interceptors.response.use(function (response) {
    console.log('我收到你的响应啦', response)
    return response.data;
}, function (error) {
    // Do something with response error
    return Promise.reject(error);
});

export default myAxios;

